package com.example.satokendemo.config;

import cn.dev33.satoken.stp.StpInterface;
import com.example.satokendemo.dao.userMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * TODO   自定义权限验证接口扩展(用于获取当前用户所有的角色和权限)
 *
 * @ClassName StpInterfaceImpl
 * @Author xiaojiang
 * @Date 2021/11/19 下午 14:12
 */
@Component
public class StpInterfaceImpl implements StpInterface {

    @Autowired
    userMapper userMapper;

    @Override
    public List<String> getPermissionList(Object loginId, String loginType) {
        String popedomName = userMapper.selectOneUserPopedom(String.valueOf(loginId));
        List<String> list = new ArrayList<String>();
        list.add(popedomName);
        return list;
    }

    @Override
    public List<String> getRoleList(Object loginId, String loginType) {
        String roleName = userMapper.selectOneUserRole(String.valueOf(loginId));
        List<String> list = new ArrayList<String>();
        list.add(roleName);
        return list;
    }
}
